/**********************************************************

     文件名称: del_cashier.c

     项目功能: 

     作者: 佳奇

     邮箱: 1374804492@qq.com 

     创建时间: Thu 25 Aug 2022 06:58:25 PM CST

**********************************************************/


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "sup_mgr.h"


static admin* del_passwd(admin* demo, int id)
{
	if(demo->next == NULL)	return NULL;

	while(demo->next != NULL && demo->next->data->user_id != id) demo = demo->next;

	if(demo == NULL)	return NULL;

	return demo;
}


//	通过员工工号 删除收银员个人信息
void del_cas(cas_list* demo)
{
	cas_list* s1 = NULL, *s2 = demo;
	admin* p1, *p2;

	int id;
	char name[31];
	system("clear");

	while(1)
	{
		printf("请输入您要删除的收银员工号：");
		
		while(1)
		{
			if(!scanf("%d", &id))
			{
				c_buffer();
				fprintf(stderr, "\n格式输入错误，请重新输入:");
			}else break;
		}
				
		c_buffer();

		while(demo->next != NULL && demo->next->data->user != id)	demo = demo->next;
		
		if(demo->next == NULL)
		{
			printf("\n您所输入的员工工号不存在!\n");
			printf("是否继续删除收银员信息(y/n):");

			if(getchar() != 'y')
   			{
				c_buffer();
            	return;
       		}
			else 
			{
				system("clear");
				demo = s2;
				c_buffer();
				continue;
			}
		}
		
		strcpy(name, demo->next->data->name);

		p1 = del_passwd(s4, id);
		p2 = p1->next;
		p1->next = p2->next;
		free(p2->data);
		free(p2);

		s1 = demo->next;	
		demo->next = s1->next;
		free(s1->data);
		free(s1);
			
		printf("\n%s员工信息删除成功！\n", name);
		printf("**********************\n");
		printf("是否继续删除收银员信息(y/n):");

		if(getchar() != 'y')
		{
			c_buffer();
			return;
		}
		else
		{
			system("clear");
			demo = s2;
			continue;
		}

		c_buffer();
	}

}	


void del_pwd(const char* demo)
{
	admin* s1 = NULL;

	while(s4->next != NULL)
	{
		if(strcmp(s4->data->user_name, demo) == 0)
		{

		}
	}
}











